﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Speech.Recognition;


namespace SpeechVoiceRecognize
{
    public class SpeechRecognizer //: ISpeechRecognizer
    {
        private SpeechRecognitionEngine _speechEngine;

        public void Initialize()
        {
            _speechEngine = new SpeechRecognitionEngine();
            // Load grammar file or add grammars, event handlers
            _speechEngine.SetInputToDefaultAudioDevice();
        }

        public void StartListening()
        {
            _speechEngine.RecognizeAsync(RecognizeMode.Multiple);
        }

        public void StopListening()
        {
            _speechEngine.RecognizeAsyncStop();
        }

        //public string GetResult()
        //{
        //    // Assuming that SpeechRecognized event is handled and there is a result in _speechEngine
        //    var result = _speechEngine.AudioState == AudioState.Stopped ?
        //                 _speechEngine.re.Text : string.Empty;
        //    return result;
        //}
    }
}
